/*
package com.weijian.advisor;

import com.weijian.common.exception.ErrorCode;
import com.weijian.common.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.ai.chat.client.advisor.api.*;
import reactor.core.publisher.Flux;

import java.util.Arrays;
import java.util.List;


*/
/**
 * 自定义违禁词校验 Advisor
 * 检查用户输入是否包含违禁词，若包含则阻止请求并返回提示信息
 * *//*

@Slf4j
public class ForbiddenWordCheckAdvisor implements CallAroundAdvisor, StreamAroundAdvisor {

    // 定义违禁词列表
    private static final List<String> FORBIDDEN_WORDS = Arrays.asList("暴力", "色情", "违法", "攻击", "学生", "帮我制定一个健身计划");

    @Override
    public String getName() {
        return this.getClass().getSimpleName();
    }

    @Override
    public int getOrder() {
        return 1; // 在日志 Advisor 之后执行
    }

    private boolean containsForbiddenWords(String text) {
        return FORBIDDEN_WORDS.stream().anyMatch(text::contains);
    }

    private AdvisedRequest before(AdvisedRequest request) {
        if (containsForbiddenWords(request.userText())) {
            log.warn("请求包含违禁词: {}", request.userText());
            throw new ServiceException(new ErrorCode(400, String.format("包含违规词: %s", request.userText())));
        }
        return request;
    }

    @Override
    public AdvisedResponse aroundCall(AdvisedRequest advisedRequest, CallAroundAdvisorChain chain) {
        advisedRequest = this.before(advisedRequest);
        return chain.nextAroundCall(advisedRequest);
    }

    @NotNull
    @Override
    public Flux<AdvisedResponse> aroundStream(@NotNull AdvisedRequest advisedRequest, @NotNull StreamAroundAdvisorChain chain) {
        advisedRequest = this.before(advisedRequest);
        return chain.nextAroundStream(advisedRequest);
    }
}
*/
